package com.briup.pts.web.controller;

import com.briup.pts.config.response.Result;
import com.briup.pts.service.UploadService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RequiredArgsConstructor
@RestController
@RequestMapping("/file/upload")
public class UploadController {
    private final UploadService uploadService;
    @PostMapping
    public Result<String> upload(@RequestPart("file") MultipartFile file){
        String url=uploadService.uploadToOss(file);
        return Result.success(url).apply("上传成功");
    }
}
